import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class MenuWidget extends StatefulWidget {
  List<DropdownMenuItem<String>> sortItems;
  String _selectedSort = '';
  Function call;
  double width;
  MenuWidget(this.sortItems, this._selectedSort, {this.call, this.width});

  @override
  _MenuWidgetState createState() => _MenuWidgetState();
}

class _MenuWidgetState extends State<MenuWidget> {
  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.only(
          left: ScreenUtil().setWidth(10), right: ScreenUtil().setWidth(10)),
      width: ScreenUtil().setWidth(widget.width == null ? 261 : 361),
      height: ScreenUtil().setHeight(40),
//      decoration: BoxDecoration(
//          border: Border.all(color: Color(0xffDCDFE6)),
//          borderRadius: BorderRadius.circular(ScreenUtil().setWidth(4))),
      child: DropdownButton(
        items: widget.sortItems,
        onChanged: (v) {
          widget._selectedSort = v;
          if (widget.call != null) {
            widget.call(widget._selectedSort);
          }
          setState(() {});
        },
        value: widget._selectedSort,
        style: TextStyle(
            color: Color(0xff101010), fontSize: ScreenUtil().setSp(14)),
        icon: Image.asset(
          "assets/assist/jiantou.png",
          width: ScreenUtil().setWidth(14),
          height: ScreenUtil().setHeight(14),
        ),
        isExpanded: true,
        underline: Text(""),
      ),
    );
  }
}
